__author__ = 'Ich'
import pygame
from constants import Constants

class Enemies(pygame.sprite.Sprite):
    global screen
    x = 0
    y = 0
    direction = 0
    # Graphic Sprite Constructor.
    def __init__(self,x,y):
        # Call the parent class (Sprite) constructor
        pygame.sprite.Sprite.__init__(self)
        # Load the image
        self.image = pygame.image.load("ball.png").convert()
        # Set our transparent color
        self.image.set_colorkey((255,255,255))
        self.rect = self.image.get_rect()
        self.rect.x = x
        self.rect.y = y

    def move(self,start=1,speed=0):
        size = Constants.getInfo()
        # Bewegungsfunktion. Direction ist die Startrichtung
        # Links = 1, Rechts = 2
        if self.direction == 0:
            self.direction = start

        if (self.rect.x < size[0]-50) and self.direction == 2: #Wenn x kleiner als Linker Rand und Richtung nach Rechts
            self.rect.x += speed
        elif self.direction == 2: #Wenn Richtung nach Rechts
            self.rect.x -= speed
            self.direction = 1


        if self.rect.x > 0 and self.direction == 1:
            self.rect.x -= speed
        elif self.direction == 1:
            self.rect.x += speed
            self.direction = 2



